#pragma once
#include <list>
#include <vector>
#include <string>

#include "triangle.h"
#include "plane.h"
#include "preprocess_helper.h"

#define INVALID_2D_COORDINATE_IN_QUERYING "Coordinate is invalid."

class TriangleWithPlane : public BaseGeo::Triangle {
public:
    BaseGeo::Plane3D plane;
    TriangleWithPlane(const BaseGeo::Triangle& triangle);
};

class StringIntf {
private:
    std::vector<TriangleWithPlane> triangles;
    PreprocessedPointsInfo preprocessed_points_info;
public:
    /// @brief Build this interface class.
    /// @param lines A vector of strings, each string likes "point_name,,x,y,z"
    /// @param shift Do the shifting in preprocessing.
    /// @param normalize Do the normalization in preprocessing.
    StringIntf(const std::vector<std::string>& lines, const bool shift = true, const bool normalize = true);

    /// @brief Execute the triangulation.
    void Triangulation();

    /// @brief Query the z for given 2d-coordinate in the Triangles-Curve.
    /// @param coord_string A string likes "x,y"
    /// @return The z in string.
    /// @retval INVALID_2D_COORDINATE_IN_QUERYING when errors occur.
    std::string QueryZ(const std::string& coord_string);
};